unit Unit59; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  db, DbCtrls, sqldb, Unit1, StdCtrls;

type

  { TForm59 }

  TForm59 = class(TForm)
    Datasource1: TDatasource;
    DBComboBox1: TDBComboBox;
    Label1: TLabel;
    SQLQuery1: TSQLQuery;
    procedure DBComboBox1Select(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    nombre_fabricante : string;
  end; 

var
  Form59: TForm59; 

implementation

{ TForm59 }

procedure TForm59.FormShow(Sender: TObject);
begin
  nombre_fabricante := '';

  if SQLQuery1.Active = true then
    SQLQuery1.Close;

  SQLQuery1.SQL.Text := 'select fab_nombre from fabricante order by fab_nombre';

  SQLQuery1.Open;
  DBComboBox1.Clear;

  DBComboBox1.DataField := 'fab_nombre';

  while not SQLQuery1.EOF do
  begin
    DBComboBox1.Items.Add(SQLQuery1.Fields[0].AsString);
    SQLQuery1.Next;
  end;

  DBComboBox1.Text := '';
end;

procedure TForm59.DBComboBox1Select(Sender: TObject);
begin
  nombre_fabricante := DBComboBox1.Text;
  Close;
end;

procedure TForm59.FormCreate(Sender: TObject);
begin
  SQLQuery1.DataBase := Form1.PQConnection1;
  SQLQuery1.Transaction := Form1.SQLTransaction1;
end;

initialization
  {$I unit59.lrs}

end.

